/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Presentation;

import Mantenimiento.Cliente;
import Mantenimiento.Empleado;
import Mantenimiento.Entradas;
import Mantenimiento.Producto;
import Mantenimiento.Proveedor;
import Mantenimiento.Vehiculo;
import Transaction.MBuscarComprobante;
import Transaction.Venta;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Rudy
 */
public class Main extends javax.swing.JFrame {

    /**
     * Creates new form Main
     */
    public static int tipe;
    public static String dni;
    public static String nombre;
    public static String usuario;
    
    public Main() {
        initComponents();
    }
    public Main(int ptipe,String pdni,String pnombre,String pusuario) {
        initComponents(); 
        tipe=ptipe;
        dni=pdni;
        nombre=pnombre;
        usuario=pusuario;
        switch(tipe)
        {
            case 1:
                lbl_tipo_user.setText("ADMINISTRADOR");
                break;
            case 2:
                lbl_tipo_user.setText("VENDEDOR");
                break;
            case 3:
                lbl_tipo_user.setText("CAJERO");
                break;
        }
        Date date = new Date();
        //SimpleDateFormat setformat = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");
        SimpleDateFormat setformat = new SimpleDateFormat("dd-MM-yyyy");
        lbl_fecha.setText(setformat.format(date));
        lbl_dni.setText(pdni);
        lbl_name.setText(pnombre);
        lbl_user.setText(pusuario);
        this.setLocationRelativeTo(null); 
    }

    public static int getTipe() {
        return tipe;
    }

    public static void setTipe(int tipe) {
        Main.tipe = tipe;
    }

    public static String getDni() {
        return dni;
    }

    public static void setDni(String dni) {
        Main.dni = dni;
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panelDesktop = new javax.swing.JDesktopPane();
        jPanel1 = new javax.swing.JPanel();
        lbl2 = new javax.swing.JLabel();
        lbl3 = new javax.swing.JLabel();
        lbl1 = new javax.swing.JLabel();
        lbl_user = new javax.swing.JLabel();
        lbl_dni = new javax.swing.JLabel();
        lbl_name = new javax.swing.JLabel();
        lbl_tipo_user = new javax.swing.JLabel();
        lbl_fecha = new javax.swing.JLabel();
        btn_cuenta = new javax.swing.JButton();
        menu = new javax.swing.JMenuBar();
        jm_matenimiento = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItemProductos = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem7 = new javax.swing.JMenuItem();
        goout = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("EDESI - > Store -> Main ");

        panelDesktop.setAutoscrolls(true);
        panelDesktop.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        panelDesktop.setFocusTraversalPolicyProvider(true);
        panelDesktop.setInheritsPopupMenu(true);

        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        lbl2.setText("  ||  DNI :");

        lbl3.setText("  ||  Nombre :");

        lbl1.setText("  ||  Usuario :");

        lbl_user.setText("xxx");

        lbl_dni.setText("xxx");

        lbl_name.setText("xxx");

        lbl_tipo_user.setText("xxx");

        lbl_fecha.setText("xxx");

        btn_cuenta.setText("Mi Cuenta");
        btn_cuenta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_cuentaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btn_cuenta, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl_tipo_user)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl_user)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl_dni)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl_name)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 184, Short.MAX_VALUE)
                .addComponent(lbl_fecha)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbl2)
                    .addComponent(lbl3)
                    .addComponent(lbl1)
                    .addComponent(lbl_user)
                    .addComponent(lbl_dni)
                    .addComponent(lbl_name)
                    .addComponent(lbl_tipo_user)
                    .addComponent(lbl_fecha)
                    .addComponent(btn_cuenta))
                .addContainerGap())
        );

        menu.setForeground(new java.awt.Color(240, 240, 240));
        menu.setFont(new java.awt.Font("Segoe UI", 0, 18));

        jm_matenimiento.setText("Mantenimiento");

        jMenuItem1.setText("Empleado");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jm_matenimiento.add(jMenuItem1);

        jMenuItem2.setText("Cliente");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jm_matenimiento.add(jMenuItem2);

        jMenuItemProductos.setText("Productos");
        jMenuItemProductos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemProductosActionPerformed(evt);
            }
        });
        jm_matenimiento.add(jMenuItemProductos);

        jMenuItem5.setText("Proveedor");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jm_matenimiento.add(jMenuItem5);

        jMenuItem6.setText("Vehiculo");
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jm_matenimiento.add(jMenuItem6);

        menu.add(jm_matenimiento);

        jMenu1.setText("Transaccion");

        jMenuItem3.setText("Entradas");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem3);

        jMenuItem4.setText("Salidas");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem4);

        jMenuItem7.setText("Modificar Conprobante");
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem7ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem7);

        menu.add(jMenu1);

        goout.setText("Salir");
        goout.setFont(new java.awt.Font("Segoe UI", 0, 14));
        goout.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                gooutMouseClicked(evt);
            }
        });
        menu.add(goout);

        setJMenuBar(menu);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(panelDesktop, javax.swing.GroupLayout.DEFAULT_SIZE, 597, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(panelDesktop, javax.swing.GroupLayout.DEFAULT_SIZE, 359, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void gooutMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_gooutMouseClicked
        // TODO add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_gooutMouseClicked

    private void btn_cuentaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_cuentaActionPerformed
       
    }//GEN-LAST:event_btn_cuentaActionPerformed

    private void jMenuItemProductosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemProductosActionPerformed
        // TODO add your handling code here:
        panelDesktop.removeAll();
        Producto fmProducto= new Producto();
       // tablaform fmProducto= new tablaform();
        panelDesktop.add(fmProducto);
        try {
          fmProducto.setMaximum(true);  
        } catch (Exception e) {
        }
        fmProducto.show();
    }//GEN-LAST:event_jMenuItemProductosActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        panelDesktop.removeAll();
        Empleado lee= new Empleado();
       // tablaform fmProducto= new tablaform();
        panelDesktop.add(lee);
        try {
          lee.setMaximum(true);  
        } catch (Exception e) {
        }
        lee.show();
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        // TODO add your handling code here:
        panelDesktop.removeAll();
        Cliente lee= new Cliente();
       // tablaform fmProducto= new tablaform();
        panelDesktop.add(lee);
        try {
          lee.setMaximum(true);  
        } catch (Exception e) {
        }
        lee.show();
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        try {
            // TODO add your handling code here:
            // TODO add your handling code here:
            panelDesktop.removeAll();
            Entradas lee= new Entradas();
           // tablaform fmProducto= new tablaform();
            panelDesktop.add(lee);
            try {
              lee.setMaximum(true);  
            } catch (Exception e) {
            }
            lee.show();
        } catch (SQLException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        // TODO add your handling code here:
        try {
            // TODO add your handling code here:
           panelDesktop.removeAll();
            Venta venta = new Venta(this);
            try {
                panelDesktop.add(venta);
                venta.setMaximum(true);
            } catch (Exception e) {
            }
            venta.show();
        } catch (SQLException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        // TODO add your handling code here:
         panelDesktop.removeAll();
        Proveedor lee= new Proveedor();
       // tablaform fmProducto= new tablaform();
        panelDesktop.add(lee);
        try {
          lee.setMaximum(true);  
        } catch (Exception e) {
        }
        lee.show();
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
        // TODO add your handling code here:
         panelDesktop.removeAll();
        Vehiculo lee= new Vehiculo();
       // tablaform fmProducto= new tablaform();
        panelDesktop.add(lee);
        try {
          lee.setMaximum(true);  
        } catch (Exception e) {
        }
        lee.show();
    }//GEN-LAST:event_jMenuItem6ActionPerformed

private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
        try {
            panelDesktop.removeAll();
            MBuscarComprobante fmBuscar= new MBuscarComprobante(this);
           // tablaform fmBuscar= new tablaform();
            panelDesktop.add(fmBuscar);
            try {
              fmBuscar.setMaximum(true);  
            } catch (Exception e) {
                e.printStackTrace();
            }
            fmBuscar.show();

        // TODO add your handling code here:
        } catch (SQLException ex) {
            
        }
// TODO add your handling code here:
}//GEN-LAST:event_jMenuItem7ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Main().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btn_cuenta;
    private javax.swing.JMenu goout;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItemProductos;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JMenu jm_matenimiento;
    private javax.swing.JLabel lbl1;
    private javax.swing.JLabel lbl2;
    private javax.swing.JLabel lbl3;
    private javax.swing.JLabel lbl_dni;
    private javax.swing.JLabel lbl_fecha;
    private javax.swing.JLabel lbl_name;
    private javax.swing.JLabel lbl_tipo_user;
    private javax.swing.JLabel lbl_user;
    private javax.swing.JMenuBar menu;
    public javax.swing.JDesktopPane panelDesktop;
    // End of variables declaration//GEN-END:variables
}
